package wiki.zimo.domain;


import wiki.zimo.annotation.Column;
import wiki.zimo.annotation.ID;
import wiki.zimo.annotation.Table;

import java.util.Objects;

/**
 * @auther: 子墨
 * @datetime: 2018/11/7 12:34
 * @describe: 订单项实体类
 */
@Table(value = "orderitem")
public class Orderitem {

    @ID(value = "itemid")
    private String itemid;

    @Column(value = "pid")
    private String pid;

    private Product product;

    @Column(value = "oid")
    private String oid;

    @Column(value = "count")
    private long count;

    @Column(value = "subTotal")
    private double subTotal;

    public String getItemid() {
        return itemid;
    }

    public void setItemid(String itemid) {
        this.itemid = itemid;
    }

    public String getPid() {
        return pid;
    }

    public void setPid(String pid) {
        this.pid = pid;
    }

    public Product getProduct() {
        return product;
    }

    public void setProduct(Product product) {
        this.product = product;
    }

    public String getOid() {
        return oid;
    }

    public void setOid(String oid) {
        this.oid = oid;
    }

    public long getCount() {
        return count;
    }

    public void setCount(long count) {
        this.count = count;
    }

    public double getSubTotal() {
        return subTotal;
    }

    public void setSubTotal(double subTotal) {
        this.subTotal = subTotal;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Orderitem orderitem = (Orderitem) o;
        return count == orderitem.count &&
                Double.compare(orderitem.subTotal, subTotal) == 0 &&
                Objects.equals(itemid, orderitem.itemid) &&
                Objects.equals(pid, orderitem.pid) &&
                Objects.equals(product, orderitem.product) &&
                Objects.equals(oid, orderitem.oid);
    }

    @Override
    public int hashCode() {

        return Objects.hash(itemid, pid, product, oid, count, subTotal);
    }

    @Override
    public String toString() {
        return "Orderitem{" +
                "itemid='" + itemid + '\'' +
                ", pid='" + pid + '\'' +
                ", product=" + product +
                ", oid='" + oid + '\'' +
                ", count=" + count +
                ", subTotal=" + subTotal +
                '}';
    }
}
